﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebFabricator.org
{
    public static class Application
    {
        static Application()
        {
            ValueProviders = new List<IValueProviderFactory>();
            WebConfiguration
                .GetSection()
                .ValueProviders
                .Cast<ValueProviderElement>()
                .Select(element => Type.GetType(element.Type))
                .Where(type => type != null)
                .ForEach(type => {
                    IValueProviderFactory factory = Activator.CreateInstance(type) as IValueProviderFactory;
                    if (factory != null)
                    {
                        ValueProviders.Add(factory);
                    }
                });

            Adorners = new List<Type>();
            WebConfiguration
               .GetSection()
               .Adorners
               .Cast<AdornerElement>()
               .Select(element => Type.GetType(element.Type))
               .Where(type => type != null)
               .ForEach(type =>
               {
                   Adorners.Add(type);
               });
        }

        public static List<Type> Adorners
        {
            get;
            private set;
        }

        public static List<IValueProviderFactory> ValueProviders
        {
            get;
            private set;
        }
    
    }

    
}
